Spawning habitat will be summarized for July, August, and September, whereas rearing habitat is summarized for June, July, and August.
##Interannual Variability of all Chinook habitat To summarize interannual variability of Chinook habitat we averaged temperatures from June 1 - September 30 for each year and plotted the results. Stanadard deviation of yearly averages represent the spatial variability of RCAs.| year | mean | std |
|---|---|---|
| 1980 | 7.99 | 2.19 |
| 1981 | 8.20 | 2.58 |
| 1982 | 7.75 | 2.11 |
| 1983 | 8.29 | 2.60 |
| 1984 | 8.95 | 2.32 |
| 1985 | 7.60 | 2.44 |
| 1986 | 7.75 | 2.16 |
| 1987 | 8.12 | 2.73 |
| 1988 | 8.32 | 2.34 |
| 1989 | 9.22 | 2.42 |
| 1990 | 8.86 | 2.39 |
| 1991 | 8.34 | 2.07 |
| 1992 | 7.41 | 3.36 |
| 1993 | 9.41 | 2.68 |
| 1994 | 8.46 | 2.62 |
| 1995 | 8.83 | 2.03 |
| 1996 | 7.96 | 2.74 |
| 1997 | 9.40 | 2.49 |
| 1998 | 7.90 | 2.29 |
| 1999 | 8.40 | 2.32 |
| 2000 | 7.81 | 2.46 |
| 2001 | 9.15 | 2.29 |
| 2002 | 8.71 | 2.35 |
| 2003 | 9.06 | 2.95 |
| 2004 | 9.58 | 3.54 |
| 2005 | 9.69 | 2.43 |
| 2006 | 8.39 | 2.02 |
| 2007 | 8.89 | 2.23 |
| 2008 | 7.72 | 2.21 |
| 2009 | 8.40 | 2.76 |
| 2010 | 8.18 | 2.16 |
| 2011 | 7.81 | 2.23 |
| 2012 | 7.74 | 2.26 |
| 2013 | 9.14 | 3.10 |
| 2014 | 8.58 | 2.50 |
| 2015 | 8.75 | 3.23 |
| 2016 | 9.74 | 2.63 |
| 2017 | 8.75 | 2.45 |
| 2018 | 9.06 | 2.22 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 6 | 7.67 | 1.97 |
| 1981 | 6 | 7.83 | 2.02 |
| 1982 | 6 | 6.83 | 1.84 |
| 1983 | 6 | 8.22 | 1.80 |
| 1984 | 6 | 8.63 | 1.83 |
| 1985 | 6 | 6.19 | 2.39 |
| 1986 | 6 | 7.30 | 2.30 |
| 1987 | 6 | 7.24 | 1.71 |
| 1988 | 6 | 8.13 | 1.72 |
| 1989 | 6 | 7.98 | 2.40 |
| 1990 | 6 | 9.00 | 2.11 |
| 1991 | 6 | 8.02 | 2.33 |
| 1992 | 6 | 7.99 | 2.09 |
| 1993 | 6 | 8.37 | 1.94 |
| 1994 | 6 | 8.25 | 2.19 |
| 1995 | 6 | 8.07 | 2.33 |
| 1996 | 6 | 7.79 | 2.30 |
| 1997 | 6 | 8.99 | 2.76 |
| 1998 | 6 | 7.80 | 2.01 |
| 1999 | 6 | 7.72 | 1.96 |
| 2000 | 6 | 7.43 | 2.20 |
| 2001 | 6 | 9.38 | 2.22 |
| 2002 | 6 | 7.98 | 2.19 |
| 2003 | 6 | 8.10 | 2.07 |
| 2004 | 6 | 9.74 | 2.36 |
| 2005 | 6 | 9.55 | 2.14 |
| 2006 | 6 | 7.82 | 1.63 |
| 2007 | 6 | 8.26 | 2.20 |
| 2008 | 6 | 6.85 | 1.91 |
| 2009 | 6 | 7.57 | 1.88 |
| 2010 | 6 | 7.42 | 1.83 |
| 2011 | 6 | 7.29 | 1.92 |
| 2012 | 6 | 7.78 | 2.36 |
| 2013 | 6 | 10.00 | 2.77 |
| 2014 | 6 | 7.56 | 2.04 |
| 2015 | 6 | 9.76 | 3.21 |
| 2016 | 6 | 9.51 | 2.05 |
| 2017 | 6 | 8.34 | 1.82 |
| 2018 | 6 | 8.01 | 1.80 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 7 | 9.62 | 1.82 |
| 1981 | 7 | 9.86 | 1.58 |
| 1982 | 7 | 9.03 | 1.88 |
| 1983 | 7 | 9.94 | 1.50 |
| 1984 | 7 | 9.95 | 1.56 |
| 1985 | 7 | 9.59 | 1.68 |
| 1986 | 7 | 9.25 | 1.76 |
| 1987 | 7 | 9.76 | 2.47 |
| 1988 | 7 | 9.96 | 1.65 |
| 1989 | 7 | 10.54 | 1.78 |
| 1990 | 7 | 9.93 | 1.68 |
| 1991 | 7 | 9.57 | 1.63 |
| 1992 | 7 | 9.73 | 1.82 |
| 1993 | 7 | 11.39 | 2.20 |
| 1994 | 7 | 9.56 | 1.81 |
| 1995 | 7 | 9.92 | 1.73 |
| 1996 | 7 | 9.75 | 1.64 |
| 1997 | 7 | 11.06 | 1.67 |
| 1998 | 7 | 9.65 | 1.64 |
| 1999 | 7 | 9.91 | 1.80 |
| 2000 | 7 | 9.19 | 2.00 |
| 2001 | 7 | 10.07 | 1.75 |
| 2002 | 7 | 10.27 | 1.74 |
| 2003 | 7 | 11.60 | 1.94 |
| 2004 | 7 | 11.76 | 2.27 |
| 2005 | 7 | 11.54 | 1.74 |
| 2006 | 7 | 9.91 | 1.62 |
| 2007 | 7 | 10.07 | 1.63 |
| 2008 | 7 | 8.76 | 1.82 |
| 2009 | 7 | 10.79 | 2.18 |
| 2010 | 7 | 8.97 | 1.69 |
| 2011 | 7 | 9.33 | 1.66 |
| 2012 | 7 | 8.50 | 1.83 |
| 2013 | 7 | 11.16 | 2.43 |
| 2014 | 7 | 10.35 | 1.78 |
| 2015 | 7 | 10.54 | 1.68 |
| 2016 | 7 | 11.69 | 1.87 |
| 2017 | 7 | 11.02 | 1.72 |
| 2018 | 7 | 10.58 | 2.20 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 8 | 8.35 | 1.60 |
| 1981 | 8 | 9.22 | 1.69 |
| 1982 | 8 | 8.91 | 1.34 |
| 1983 | 8 | 9.55 | 1.75 |
| 1984 | 8 | 10.31 | 2.46 |
| 1985 | 8 | 8.48 | 1.50 |
| 1986 | 8 | 8.06 | 1.51 |
| 1987 | 8 | 9.87 | 1.60 |
| 1988 | 8 | 9.39 | 1.50 |
| 1989 | 8 | 10.55 | 1.67 |
| 1990 | 8 | 10.02 | 1.80 |
| 1991 | 8 | 8.63 | 1.50 |
| 1992 | 8 | 8.55 | 2.18 |
| 1993 | 8 | 10.63 | 1.82 |
| 1994 | 8 | 9.98 | 2.25 |
| 1995 | 8 | 9.24 | 1.57 |
| 1996 | 8 | 9.07 | 1.49 |
| 1997 | 8 | 10.11 | 1.59 |
| 1998 | 8 | 8.00 | 2.22 |
| 1999 | 8 | 9.45 | 1.78 |
| 2000 | 8 | 8.94 | 1.93 |
| 2001 | 8 | 10.23 | 1.71 |
| 2002 | 8 | 9.62 | 1.83 |
| 2003 | 8 | 10.15 | 2.29 |
| 2004 | 8 | 11.60 | 1.97 |
| 2005 | 8 | 10.36 | 1.74 |
| 2006 | 8 | 8.87 | 1.66 |
| 2007 | 8 | 10.05 | 1.62 |
| 2008 | 8 | 8.93 | 1.58 |
| 2009 | 8 | 8.96 | 1.56 |
| 2010 | 8 | 9.21 | 1.69 |
| 2011 | 8 | 8.54 | 1.65 |
| 2012 | 8 | 8.73 | 1.53 |
| 2013 | 8 | 9.47 | 1.61 |
| 2014 | 8 | 9.65 | 1.89 |
| 2015 | 8 | 9.50 | 2.09 |
| 2016 | 8 | 10.61 | 1.52 |
| 2017 | 8 | 9.07 | 2.08 |
| 2018 | 8 | 9.75 | 1.90 |
| year | month | mean | std |
|---|---|---|---|
| 1980 | 9 | 6.24 | 1.89 |
| 1981 | 9 | 5.78 | 2.76 |
| 1982 | 9 | 6.14 | 1.63 |
| 1983 | 9 | 5.37 | 2.42 |
| 1984 | 9 | 6.84 | 1.53 |
| 1985 | 9 | 6.05 | 1.98 |
| 1986 | 9 | 6.31 | 1.83 |
| 1987 | 9 | 5.50 | 2.20 |
| 1988 | 9 | 5.71 | 1.82 |
| 1989 | 9 | 7.72 | 2.14 |
| 1990 | 9 | 6.43 | 1.98 |
| 1991 | 9 | 7.09 | 1.89 |
| 1992 | 9 | 3.27 | 2.96 |
| 1993 | 9 | 7.16 | 2.31 |
| 1994 | 9 | 5.99 | 2.19 |
| 1995 | 9 | 8.04 | 1.75 |
| 1996 | 9 | 5.14 | 2.73 |
| 1997 | 9 | 7.36 | 2.09 |
| 1998 | 9 | 6.12 | 1.76 |
| 1999 | 9 | 6.43 | 1.87 |
| 2000 | 9 | 5.62 | 1.89 |
| 2001 | 9 | 6.83 | 1.65 |
| 2002 | 9 | 6.89 | 1.99 |
| 2003 | 9 | 6.26 | 2.28 |
| 2004 | 9 | 5.10 | 2.64 |
| 2005 | 9 | 7.22 | 1.77 |
| 2006 | 9 | 6.91 | 1.82 |
| 2007 | 9 | 7.08 | 1.83 |
| 2008 | 9 | 6.27 | 2.17 |
| 2009 | 9 | 6.19 | 2.84 |
| 2010 | 9 | 7.04 | 2.48 |
| 2011 | 9 | 5.99 | 2.08 |
| 2012 | 9 | 5.88 | 2.09 |
| 2013 | 9 | 5.84 | 2.58 |
| 2014 | 9 | 6.68 | 2.30 |
| 2015 | 9 | 5.11 | 2.58 |
| 2016 | 9 | 7.07 | 2.44 |
| 2017 | 9 | 6.46 | 1.64 |
| 2018 | 9 | 7.83 | 1.61 |
#Mean daily temperatures across 38 year period
#histograms of percent habitat for each degree celcius - Chinook Presence habitat
#histograms of percent habitat for each degree celcius - Chinook Spawning habitat
#histograms of percent habitat for each degree celcius - Chinook Rearing habitat
##Daily mean tempertures for each year (1980-2018)
#Animate by Year using gganimate
#https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/
#shadow fade with old years in background
theme_set(theme_bw())
ani <- ggplot(all_years, aes(x = day, y = mean_yr, color = as.factor(year))) +
geom_smooth(se=FALSE, show.legend = FALSE) +
scale_size(range = c(2, 12)) +
transition_states(year, transition_length = 1, state_length = 1) + shadow_mark(alpha=0.3, size=0.7) +
transition_time (year) +
labs(x = "Day of Year", y = "Daily mean Stream Temperature", title = "Year: {as.integer(frame_time)}")
animate(ani, duration=50, fps=1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#try the "Let data gradually appear" with month time series
K_p2 <- preds %>% mutate(month=month(date), day2=(day(date))) %>% mutate(decade=case_when(year< 1990 ~ 1980, year >= 1990 & year < 2000 ~ 1990, year >=2000 & year < 2010 ~ 2000, year>2009 ~ 2010)) %>% filter(K_p == 1)
all_years2 <- K_p2 %>% group_by(month, day2) %>%
summarize(mean_mth = mean(preds))
ani2 <- ggplot(all_years2, aes(x = day2, y = mean_mth, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures 1980-2018")
ani2 + transition_reveal(day2)
##Animate months by decade
all_years22 <- K_p2 %>% group_by(month, day2, decade) %>%
summarize(mean_mth_dec = mean(preds))
ggplot(all_years22, aes(x = day2, y = mean_mth_dec, color=factor(month))) +
geom_line() + facet_wrap(~decade) +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures by decade")
ggsave("Anchor_chinook_plots/Average Daily Temps Animated.jpeg", plot=last_plot())
## Saving 4 x 4 in image
ani3 <- ggplot(all_years22, aes(x = day2, y = mean_mth_dec, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures by decade")
ani3 + transition_reveal(day2) + facet_wrap(~decade)
##Summarize predictions by decades and plot
##Calculate and plot Temperature Anomolies!
#Filter for spawning time period - Chinook reach their spawning areas between July and September - DESCENDING LIMB!!!!
#Filter for core rearing - June-August